<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /**
         * @param {string[]} strs
         * @return {string}
         */
        var longestCommonPrefix = function(strs) {
            if(strs.length == 0) 
                return "";
            let ans = strs[0];
            for(let i =1;i<strs.length;i++) {
                let j=0;
                for(;j<ans.length && j < strs[i].length;j++) {
                    if(ans[j] != strs[i][j])
                        break;
                }
                ans = ans.substr(0, j);
                if(ans === "")
                    return ans;
            }
            return ans;

        };
        console.log(longestCommonPrefix(["a"]))
    </script>
</body>
</html>